package com.LC._746;

public class Solution {
    public int minCostClimbingStairs(int[] cost) {
        //定义dp 数组下标含义
        //第一步不花钱
        int[] dp = new int[cost.length];//dp[i]的定义：到达第i个台阶所花费的最少体⼒为dp[i]
        //递推公式dp[i] = Math.min(dp[i-1] , dp[i-2]) + cost[i];
        //初始化
        dp[0] = cost[0];
        dp[1] = cost[1];
        for (int i = 2; i < cost.length; i++) {
            dp[i] = Math.min(dp[i-1] , dp[i-2]) + cost[i];
            System.out.println(dp[i] +"-------dp[]");
        }
        return Math.min(dp[cost.length-1] , dp[cost.length-2]);
//        return dp[cost.length-1];

    }

    public static void main(String[] args) {
        Solution solution = new Solution();
        int[] nums;
        nums =new int[]{1,100,1,1,1,100,1,1,100,1};
        System.out.println(solution.minCostClimbingStairs(nums));

    }
}
